import requests
from typing import Generator, Dict

BOT_TOKEN = "6137177804:AAEXZ4f7T8o4ZATEZXZd25CEPpI4CVZwV2Y"

GET_UPDATES_URL = f"https://api.telegram.org/bot{BOT_TOKEN}/getUpdates"


def get_updates() -> Generator[Dict, None, None]:
    offset = -100
    while True:
        resp = requests.post( GET_UPDATES_URL, data={"offset": offset, "limit": 100})
        ok, result = resp.json().values()
        if ok and result:
            update_id, _ = result[-1].values()
            offset = update_id + 1
        yield result